﻿using Prism.Commands;
using SmartPlant.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartPlant.Modules.Base.UIEntity
{
    public class ContextOperationModel
    {
        public string Header { get; set; }
        public string IconGlyph { get; set; }
        /// <summary>
        /// 大概率会直接在xaml里绑定command。如Setter Property="Command" Value="{Binding Command}"。
        /// 带了一个object参数，可以xaml里再绑定一个CommandParameter进去。
        /// </summary>
        public DelegateCommand<object> Command { get; set; }
        public bool IsSeparator { get; set; }

        private ContextType type;

        public ContextType ContextType
        {
            get { return type; }
            set
            {
                type = value;
                switch (type)
                {
                    case ContextType.Create://初始化时给一个默认值和照片
                        IconGlyph = "&#xe11e;";
                        break;

                    case ContextType.Copy:
                        IconGlyph = "&#xe65d;";
                        break;

                    case ContextType.Delete:
                        IconGlyph = "&#xe10c;";
                        break;

                    case ContextType.Update:
                        IconGlyph = "&#xe600;";
                        break;

                    default:
                        break;
                }
            }
        }

        public ObjectDefId ObjectType { get; set; }
        public ContextOperationModel(string header, ContextType contextType, ObjectDefId objectType, DelegateCommand<object> delegateCommand)
        {
            Header = header;
            ObjectType = objectType;
            ContextType = contextType;
            Command = delegateCommand;
        }
    }
    /// <summary>
    /// 右键菜单的类型？(或者理解为动作类型)
    /// </summary>
    public enum ContextType
    {
        Create,
        Copy,
        Delete,
        //默认就选择这个
        Update,
        PDGeneral,
        Spec,
        ApplyFilter,
        UnApplyFilter,
        Rename,
        Revision
    }
}
